package com.joysuch.wwyt.mh.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum MajorHazardLevelEnum {

    LEVEL_1("一级", "一级危险源"),
    LEVEL_2("二级", "二级危险源"),
    LEVEL_3("三级", "三级危险源"),
    LEVEL_4("四级", "四级危险源"),
    LEVEL_0("非重大", "非重大危险源"),
    // 此级别数据库不存, 只是为了列表查询匹配
    LEVEL_9999("重大危险源", "重大危险源");

    private String level;
    private String desc;

    MajorHazardLevelEnum(String level, String desc) {
        this.level = level;
        this.desc = desc;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static final Map<String, MajorHazardLevelEnum> lookup = new HashMap<>();

    static {
        for (MajorHazardLevelEnum e : EnumSet.allOf(MajorHazardLevelEnum.class)) {
            lookup.put(e.level, e);
        }
    }

    public static MajorHazardLevelEnum find(String level) {
        if (null == level) {
            return null;
        }
        return lookup.get(level);
    }

}
